import Vue from 'vue'
import Vuex from 'vuex'

//挂载Vuex
Vue.use(Vuex)

//创建VueX对象
const store = new Vuex.Store({
    state:{
        //存放的键值对就是所要管理的状态
        userId:null,
        token:null
    },
    mutations: {
      SET_USERID (state, userId) {
        state.userId = userId
      },
      SET_TOKEN (state, token) {
        state.token = token
      }
	    },
    actions:{
      setUserId ({commit}, userId) {
        commit('SET_USERID', userId)
      },
      setToken ({commit}, token) {
        commit('SET_TOKEN', token)
      }
	}
})

export default store
